{% extends 'index.html' %}
{% block head_css_js %}
    <link href="/static/css/custom.css" rel="stylesheet">
    <script src="/static/plugins/ckeditor/ckeditor.js"></script>

{% endblock %}

{% block page-container %}
    <h3>发布新贴</h3>
    <div class="new-article">
        {% if new_article_obj %}
            <h3>文章:《{{ new_article_obj.title }}》已经成功发布，<a href="{% url 'article_detail' new_article_obj.id %}">查看详情</a>
            </h3>
        {% else %}
            <form action="{% url 'new_article' %}" method="post" enctype="multipart/form-data">{% csrf_token %}
                <input name="title" type="text" class="form-control" placeholder="文章标题">
                <select name="category_id" id="" class="form-control"><!--版块选择-->
                    {% for category in category_list %}
                        <option value="{{ category.id }}">{{ category.name }}</option>
                    {% endfor %}
                </select>
                <input name="summary" type="text" class="form-control" placeholder="文章简介">
                <input type="file" name="head_img">标题图片(必选)
                <textarea name="content" id="ck-editor" cols="30" rows="10"></textarea>
                <button type="submit" class="btn btn-success pull-right">发贴</button>
            </form>
            {% if msg %}
                <div class="list-inline error_msg" style="color: red;">{{ msg.errors }}</div>
            {% endif %}
        {% endif %}
    </div>
{% endblock %}

{% block foot_js %}
    <script>
         CKEDITOR.replace( 'ck-editor' );//调用富文本
        CKEDITOR.editorConfig = function( config ) {
            //config.language = 'fr';
            config.uiColor = '#AADC6E';
        };
    </script>
{% endblock %}